var CdcOrdgroupEntry = {
    id: "CdcOrdEntryTable",	//表格id
    ordGroupId:0,
    seItem: null,		//选中的条目
    table: null,
    layerIndex: -1
};

CdcOrdgroupEntry.initColumn = function () {
    return [
        {field: 'selectItem', radio: true},
        {title: '医嘱项', field: 'orderMast.description', align: 'center', valign: 'middle', sortable: true,width:200},
        //{title: '属性', field: 'orderRole.description', align: 'center', width: '120px', valign: 'middle',width:80},
        {title: '医嘱ID', field: 'orderMast.id', align: 'center', valign: 'middle', sortable: true,width:150}
    ];
};

CdcOrdgroupEntry.check = function () {
    var selected = $('#' + this.id).bootstrapTable('getSelections');
    if(selected.length == 0){
        Sys.info("请先选中表格中的某一记录！");
        return false;
    }else{
        CdcOrdgroupEntry.seItem = selected[0];
        return true;
    }
};

CdcOrdgroupEntry.add = function(){
    if (CdcOrdgroupEntry.ordGroupId == 0) {
        Sys.info("请先选中一条医嘱套记录！");
        return false;
    }
    var index = Sys.open('医嘱项列表',Sys.backendPath + '/cdc/cdcordgroup/to_list',['800px', '480px']);
        this.layerIndex = index;
}
CdcOrdgroupEntry.del = function(id){
    var flag = false;
	if(id){
		flag = true;
	}else if (this.check()) {
        id = this.seItem.id;
        flag = true;
    }
	if (flag) {
        var operation = function(){
	        var ajax = new $ax(Sys.backendPath + "/cdc/cdcordgroupentry/delete", function (data) {
	            Sys.success("删除成功!");
	            CdcOrdgroupEntry.table.refresh();
	        }, function (data) {
	            Sys.error("删除失败!" + data.responseJSON.message + "!");
	        });
	        ajax.set("cdcOrdgroupEntryId",id);
	        ajax.start();
	    };
	    Sys.confirm("是否删除医嘱套明细?",operation);
    }
}
$(function () {
    CdcOrdgroupEntry.sysDataId=CdcOrdgroup.sysDataId;

    var defaultColunms = CdcOrdgroupEntry.initColumn();
    var table = new BSTable(CdcOrdgroupEntry.id, Sys.backendPath + "/cdc/cdcordgroupentry/list", defaultColunms);
    table.setPaginationType("server");
    table.setShowRefresh(false);
    table.setShowColumns(false);
    table.setShowToggle(false);
    table.setShowExport(false);
    table.setPageSize(10);
    table.setQueryParams({ "NotQuery": "true" });
    CdcOrdgroupEntry.table = table.init();
});